home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Information / CSMP Digest / volume 3 / csmp-digest-v3-142 < prev    next >
Encoding:
Text File  |  1996-03-31  |  38.7 KB  |  1,139 lines  |  [TEXT/R*ch]

  1. C.S.M.P. Digest             Thu, 28 Mar 96       Volume 3 : Issue 142
  2.  
  3. Today's Topics:
  4.  
  5.         "volatile" variables?
  6.         A Good Random-number Generator (here it is!)
  7.         Apple Event handlers & C++
  8.         CodeWarrior - faster code than MrC?
  9.         Desktop pattern for a window
  10.         Direct-to-screen drawing and Copland
  11.         Shareware Modula-2 compiler for Mac
  12.         Sharing Name
  13.         Writing a scriptable app
  14.         [Q] How to write a FAT inline LDEF
  15.         [Q] Where is the NBP queue located on an Open Transport-based Mac?
  16.         gworlds 7.5.3
  17.  
  18.  
  19.  
  20. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  21. (pottier@clipper.ens.fr).
  22.  
  23. The digest is a collection of article threads from the internet
  24. newsgroups comp.sys.mac.programmer.help, csmp.tools, csmp.misc and
  25. csmp.games. It is designed for people who read news semi-regularly and
  26. want an archive of the discussions.  If you don't know what a
  27. newsgroup is, you probably don't have access to it. Ask your systems
  28. administrator(s) for details. If you don't have access to news, you
  29. may still be able to post messages to the group by using a mail server
  30. like anon.penet.fi (mail help@anon.penet.fi for more information).
  31.  
  32. Each issue of the digest contains one or more sets of articles (called
  33. threads), with each set corresponding to a 'discussion' of a particular
  34. subject.  The articles are not edited; all articles included in this digest
  35. are in their original posted form (as received by our news server at
  36. nef.ens.fr).  Article threads are not added to the digest until the last
  37. article added to the thread is at least two weeks old (this is to ensure that
  38. the thread is dead before adding it to the digest).  Article threads that
  39. consist of only one message are generally not included in the digest.
  40.  
  41. The digest is officially distributed by two means, by email and ftp.
  42.  
  43. If you want to receive the digest by mail, send email to listserv@ens.fr
  44. with no subject and one of the following commands as body:
  45.     help                        Sends you a summary of commands
  46.     subscribe csmp-digest Your Name    Adds you to the mailing list
  47.     signoff csmp-digest            Removes you from the list
  48. Once you have subscribed, you will automatically receive each new
  49. issue as it is created.
  50.  
  51. The official ftp info is ftp://ftp.dartmouth.edu/pub/csmp-digest.
  52. Questions related to the ftp site should be directed to
  53. scott.silver@dartmouth.edu.
  54.  
  55. -------------------------------------------------------
  56.  
  57. >From jim@bogie2.bio.purdue.edu (Jim Cavera)
  58. Subject: "volatile" variables?
  59. Date: Wed, 06 Mar 1996 12:40:51 -0500
  60. Organization: Purdue University
  61.  
  62. In some example code on the CW reference CD, I see some variables
  63. with a modifier of "volatile".  In example :
  64.  
  65. volatile short   result     = 0;
  66.  
  67. Could someone give me a simplistic explanation of (a) what this
  68. means and (b) why someone would want to do it?  Thanks in
  69. advance.
  70.  
  71. - Jim Cavera (bit-pushing slave)
  72. jim@bogie2.bio.purdue.edu
  73.  
  74. +++++++++++++++++++++++++++
  75.  
  76. >From rickgenter@aol.com (RickGenter)
  77. Date: 6 Mar 1996 15:05:03 -0500
  78. Organization: America Online, Inc. (1-800-827-6364)
  79.  
  80. In article <jim-0603961240510001@ibcrc3.bio.purdue.edu>,
  81. jim@bogie2.bio.purdue.edu (Jim Cavera) writes:
  82.  
  83. >In some example code on the CW reference CD, I see some variables
  84. >with a modifier of "volatile".  In example :
  85. >
  86. >volatile short   result     = 0;
  87. >
  88. >Could someone give me a simplistic explanation of (a) what this
  89. >means and (b) why someone would want to do it?  Thanks in
  90. >advance.
  91.  
  92. A volatile variable is one whose value may change outside the scope of the
  93. program. Two examples are:
  94.  
  95. - memory mapped I/O registers - reading the same location twice in a row
  96. may result in different values
  97. - global variables shared by several threads/processes, or accessed by an
  98. interrupt handler. For example, the ioResult parameter of any parameter
  99. block should be declared volatile, because it can be changed "out from
  100. underneath the program."
  101.  
  102. The volatile declaration is used to prevent the compiler from optimizing
  103. access to the variable by loading it into a register and keeping it there.
  104. A volatile variable must be loaded from memory on each access.
  105.  
  106. Rick Genter
  107. Papyrus Design Group, Inc.
  108.  
  109. +++++++++++++++++++++++++++
  110.  
  111. >From "Andrew C. Plotkin" <erkyrath+@CMU.EDU>
  112. Date: Wed,  6 Mar 1996 14:44:00 -0500
  113. Organization: Carnegie Mellon, Pittsburgh, PA
  114.  
  115. jim@bogie2.bio.purdue.edu (Jim Cavera) writes:
  116. > In some example code on the CW reference CD, I see some variables
  117. > with a modifier of "volatile".  In example :
  118. > volatile short   result     = 0;
  119. > Could someone give me a simplistic explanation of (a) what this
  120. > means and (b) why someone would want to do it?  Thanks in
  121. > advance.
  122.  
  123. volatile means that the variable can change without the program
  124. changing it. For example, a memory-mapped IO location can be changed
  125. at arbitrary times by the IO hardware. The compiler has to know this,
  126. because otherwise it might optimize away important reads. For example,
  127.  
  128. while (io_loc) { 
  129.   counter++;
  130. };
  131.  
  132. might be optimized to only read io_loc once, since it looks like
  133. io_loc never changes during the loop.  If you declare io_loc to be
  134. volatile, the compiler knows not to do that.
  135.  
  136. Why would someone want to do it? It's important in writing
  137. interrupt-driven code, like device drivers. I've never had a use for
  138. it. (Even when writing interrupt-time code like sound manager
  139. callbacks.)
  140.  
  141. --Z
  142.  
  143. "And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."
  144.  
  145. +++++++++++++++++++++++++++
  146.  
  147. >From Tom Smith <tom_smith@moldev.com>
  148. Date: Wed, 06 Mar 1996 16:20:00 -0800
  149. Organization: Molecular Devices
  150.  
  151. Andrew C. Plotkin wrote:
  152. > jim@bogie2.bio.purdue.edu (Jim Cavera) writes:
  153. > > In some example code on the CW reference CD, I see some variables
  154. > > with a modifier of "volatile".  In example :
  155. > >
  156. > > volatile short   result     = 0;
  157. > >
  158. > > Could someone give me a simplistic explanation of (a) what this
  159. > > means and (b) why someone would want to do it?  Thanks in
  160. > > advance.
  161. > volatile means that the variable can change without the program
  162. > changing it. For example, a memory-mapped IO location can be changed
  163. > at arbitrary times by the IO hardware. The compiler has to know this,
  164. > because otherwise it might optimize away important reads. For example,
  165. > while (io_loc) {
  166. >   counter++;
  167. > };
  168. > might be optimized to only read io_loc once, since it looks like
  169. > io_loc never changes during the loop.  If you declare io_loc to be
  170. > volatile, the compiler knows not to do that.
  171. > Why would someone want to do it? It's important in writing
  172. > interrupt-driven code, like device drivers. I've never had a use for
  173. > it. (Even when writing interrupt-time code like sound manager
  174. > callbacks.)
  175. >
  176.  
  177. I once needed it when writing a memory test.  The code would write out 
  178. to a memory location and then expect to read back the same thing.  The 
  179. first pass worked so well, it found memory where there wasn't any.  The 
  180. compiler would write the location, but didn't bother to ever read it 
  181. back in because it "knew" what was there.
  182.  
  183. +++++++++++++++++++++++++++
  184.  
  185. >From jonpugh@netcom.com (Jon Pugh)
  186. Date: Sun, 10 Mar 1996 20:54:10 GMT
  187. Organization: Apple Computer
  188.  
  189. In article <jim-0603961240510001@ibcrc3.bio.purdue.edu>,
  190. jim@bogie2.bio.purdue.edu (Jim Cavera) wrote:
  191.  
  192. >In some example code on the CW reference CD, I see some variables
  193. >with a modifier of "volatile".  In example :
  194. >
  195. >volatile short   result     = 0;
  196. >
  197. >Could someone give me a simplistic explanation of (a) what this
  198. >means and (b) why someone would want to do it?  Thanks in
  199. >advance.
  200.  
  201. You've heard what it does, but the other reason to do it is because of
  202. setjmp & longjmp which some people are still using in their exception
  203. macros.  If you have a variable or object which is referenced by a pointer
  204. before a call to setjmp and then the register state is restored by a call
  205. to longjmp, then you could have an old value in the register if you don't
  206. use the volatile keyword.
  207.  
  208. Jon
  209.  
  210. -- 
  211. What are YOU doing to oppose the Microsoft juggernaut?
  212.          http://www.infoworkshop.com/~jonpugh/
  213.  
  214. +++++++++++++++++++++++++++
  215.  
  216. >From dbrosius@chesco.com (Dave M Brosius)
  217. Date: 10 Mar 1996 08:45:56 GMT
  218. Organization: Chester County Internet Services, Inc.
  219.  
  220. In article <jim-0603961240510001@ibcrc3.bio.purdue.edu>,
  221. jim@bogie2.bio.purdue.edu (Jim Cavera) wrote:
  222.  
  223. > In some example code on the CW reference CD, I see some variables
  224. > with a modifier of "volatile".  In example :
  225. > volatile short   result     = 0;
  226. > Could someone give me a simplistic explanation of (a) what this
  227. > means and (b) why someone would want to do it?  Thanks in
  228. > advance.
  229. > - Jim Cavera (bit-pushing slave)
  230. > jim@bogie2.bio.purdue.edu
  231.  
  232. If a variable is going to change values outside of the normal code logic,
  233. you must declare it volatile, so that the compiler knows to check it each
  234. time.
  235.  
  236. consider an asynchronous write
  237.  
  238.    rPB.ioParam.ioCompletion = NULL;
  239.    rPB.ioParam.ioReqCount = 10240;
  240.    rPB.ioParam.ioBuffer = &myData;
  241.    rPB.ioParam.ioPosMode = fsFromMark;
  242.    rPB.ioParam.ioPosOffset = 0;
  243.  
  244.    iErr = PBWrite( &rPB, true ); // <- look asynchronous
  245.  
  246.    while (rPB.ioParam.ioResult == 1)
  247.    {
  248.         SpinCursor( ); 
  249.         DroolDownChin( );
  250.    }
  251.  
  252.  
  253.    Notice that in the while loop, there's nothing that's going to
  254. change rPB.ioParam.ioResult. It happens asynchronously. The compiler may
  255. say to itself, I can optimize this by copying rPB.ioParam.ioResult into a 
  256. register before the while loop, and just checking the register each time
  257. through the loop. A really optimizing compiler wouldn't even check it at all
  258. (after the first time).
  259.  
  260. By saying volatile, your telling the compiler, that, even though it seems
  261. silly, check the actual variable every stinkin' time through the loop.
  262.  
  263. HTH
  264.  
  265. -- 
  266. Please reply via email as well
  267. dave dbrosius@chesco.com
  268.  
  269. ---------------------------
  270.  
  271. >From "Michael P. McLaughlin" <mpmcl@mitre.org>
  272. Subject: A Good Random-number Generator (here it is!)
  273. Date: Mon, 11 Mar 1996 13:48:13 -0509
  274. Organization: The MITRE Corporation
  275.  
  276. I've seen many requests here and elsewhere for random-number code for the Mac.  Usually, the 
  277. requests are for something that is very good (i.e., random) or really fast or with a very long 
  278. period.
  279.  
  280. In our group, we are heavy users of such generators (billions of random-number calls per week) 
  281. because we do a *lot* of Monte Carlo simulation (100 percent Macintosh).  Since I've been the 
  282. recipient of much good (free) advice from newsgroups like this one, I thought I'd offer partial 
  283. repayment, in kind, by placing this random-number library in the public domain.  It is very random 
  284. AND very fast AND has a very long period.  In fact, modesty aside, I doubt that there is a better 
  285. one publically available anywhere.  
  286.  
  287. The easiest way to find it is to go to Web site
  288.  
  289. http://hyperarchive.lcs.mit.edu/HyperArchive.html
  290.  
  291. and search for
  292.  
  293. RandomNumberLib
  294.  
  295. The body of the README file is reproduced below:
  296.  
  297. UltraLibU  --  A pseudo-random-number library for Macintosh platforms
  298.  
  299. This library is a new C/Assembly implementation of the Ultra PRNG developed by Marsaglia, et al. 
  300. (see leading reference in source).  It is designed primarily for Macintosh platforms and replaces 
  301. an earlier (non-PPC) library, by this author, that is currently available in a number of public 
  302. archives.
  303.  
  304. UltraLibU contains one low-level assembly routine, in a conditional-compilation block, for MC68020 
  305. (and higher) or PowerPC processors.  (Note: Pure C source for this routine is already available in 
  306. the usual Internet archives.)  The assembly syntax is that of Metrowerks' CodeWarrior<TM> but 
  307. adaptation to other compilers should be trivial.
  308.  
  309. Requirements:
  310.  
  311. Either an MC68020 (or higher) processor or a PowerPC processor.
  312. A C compiler with an assembler for the processor used.
  313.  
  314. Public functions:
  315.  
  316. 7 functions returning various forms of uniform long/short variates
  317. 1 function  returning Boolean variates
  318. 2 functions returning (float) U(0,1) and (float) U(-1,1) variates
  319. 2 functions returning (double) U(0,1) and (double) U(-1,1) variates
  320. 1 function  returning (float) Normal(mu,sigma) variates [exact, not approximate]
  321. 1 function  returning (float) Exponential(mu) variates  [exact, not approximate]
  322.  
  323. 1 function to initialize the library
  324. 2 functions to save and restore the status of the PRNG [to reproduce a sequence exactly]
  325.  
  326. Special features:
  327.  
  328. Variates are HIGHLY RANDOM.  This PRNG uses a compound generator and produces numbers that are 
  329. random even at the bit level.  Moreover, all the bits in each variate are random, not just the most 
  330. sigificant bits.
  331.  
  332. Execution is VERY FAST, e.g.,
  333. Booleans  -->   0.65 and 0.23 microseconds each on a Quadra 800 and PowerMac 9500/120, resp.
  334. Normals   -->  24.0  and 2.74 microseconds each on a Quadra 800 and PowerMac 9500/120, resp.
  335. [complete timing list in source]
  336.  
  337. The (float) U(0,1) and (float) U(-1,1) variates are automatically scaled.  Their mantissas always 
  338. have at least 25 bits of precision no matter how small the return values.  Neither returns zero.
  339.  
  340. The period of this compound generator exceeds 10^356.
  341.  
  342. - ------------------------------------------------------------------------------------------------
  343.  
  344. This package contains the following files:
  345.  
  346. (this file)
  347. UltraLibU.c         (the library)
  348. UltraU.h            (an essential header file)
  349. UltraUTest.c        (a demonstration/test program)
  350. UltraUTest.out.org  (the expected output of the test program, with Quadra 800 timing)
  351.  
  352. - ------------------------------------------------------------------------------------------------
  353.  
  354. -- 
  355. Dr. Michael P. McLaughlin (mpmcl@mitre.org)
  356. Center for Advanced Aviation System Development
  357. The MITRE Corporation, McLean VA, USA
  358.  
  359. ---------------------------
  360.  
  361. >From brinda@cvo.oneworld.com (John Brinda)
  362. Subject: Apple Event handlers & C++
  363. Date: Mon, 11 Mar 1996 01:07:38 -0800
  364. Organization: None
  365.  
  366. Anyone have a simple way to add AE handlers to a small C++ application shell?
  367.  
  368. I keep getting "illegal use of a non-static member" errors, and I don't
  369. want to make everything in my class static if I can help it...
  370.  
  371. TIA
  372.  
  373. -- John Brinda 
  374. -- <A HREF="http://brinda.com/">Homepage</A>
  375. -- <A HREF="mailto:john@brinda.com">E-Mail</A>
  376. -- <A HREF="http://brinda.com/pgpkey.asc">PGP</A>
  377.  
  378. +++++++++++++++++++++++++++
  379.  
  380. >From brinda@cvo.oneworld.com (John Brinda)
  381. Date: Tue, 12 Mar 1996 08:49:46 -0800
  382. Organization: None
  383.  
  384. In article <tulip-1103962042590001@tulip.tiac.net>, tulip@tiac.net (Ed
  385. Anson) wrote:
  386.  
  387. >> Anyone have a simple way to add AE handlers to a small C++ application shell?
  388. >> 
  389. >> I keep getting "illegal use of a non-static member" errors, and I don't
  390. >> want to make everything in my class static if I can help it...
  391. >
  392. >Only the AE handlers need to be static.
  393.  
  394. First, thanks to the two people who replied. As always there are two ways
  395. to accomplish this -- an easy way and a more elegant way.
  396.  
  397. The easy way is to create a static data member that points to the current
  398. application (App::App() {fCurrentApplication = this;}) and use that
  399. information to call the object methods from within the static handler. The
  400. more elegant way is to put this information in the AE user data.
  401.  
  402. I chose the easy way for now. Maybe after reading Dave Mark's Ultimate Mac
  403. Programming I'll know enough about apple events to do it the other way.
  404. Somebody really needs to write a good C++ book for the Mac. The only one
  405. I've found is "Elements of C++ Macintosh Programming," which is good, but
  406. predates System 7.
  407.  
  408. -- John Brinda 
  409. -- <A HREF="http://brinda.com/">Homepage</A>
  410. -- <A HREF="mailto:john@brinda.com">E-Mail</A>
  411. -- <A HREF="http://brinda.com/pgpkey.asc">PGP</A>
  412.  
  413. ---------------------------
  414.  
  415. >From mars@netcom.com (Darren Giles)
  416. Subject: CodeWarrior - faster code than MrC?
  417. Date: Fri, 8 Mar 1996 11:37:40 GMT
  418. Organization: Terran Interactive
  419.  
  420. SUMMARY:
  421. MrC seems to produce slower code than CodeWarrior!  (At least, in my case)
  422.  
  423. THE BACKGROUND:
  424. I'm trying to squeeze that last erg of performance out of some algorithms
  425. I'm working on.  There are several routines that need to be optimized. 
  426. Each is about 20-50 lines long, mainly nested loops... no function
  427. calls... *simple* pointer, integer, & float arithmatic.  I've done about
  428. everything I can think of to the C code, and I want to avoid assembly. 
  429. The only thing left seems to be the compiler.
  430.  
  431. THE ENVIRONMENT:
  432. I'm using CodeWarrior as my main development environment, and I keep
  433. hearing how MrC and the Motorola compilers produce tighter code.  So I
  434. tried compiling one of my routines with MPW/MrC, exporting it as a
  435. library, and linking with the rest of the project in CodeWarrior.
  436.  
  437. THE RESULTS:
  438. MrC seemed to produce much *slower* code in this case:
  439.           CodeWarrior v.8       : 175 mSec
  440.           MPW/MrC 1.0           : 287 mSec
  441.           MPW/MrC 2.0d1         : 208 mSec
  442. And yes, I am using the -opt speed flag.
  443.  
  444. THE QUESTIONS:
  445. Should I be thrilled that CodeWarrior seems better than it gets credit for?
  446. Should I be disappointed that MrC didn't provide the edge I hoped for?
  447. Is there anything special I need to do to take advantage of MrC?
  448. Is there any way I can get ahold of a evaluation version of the Motorola
  449. compiler so I don't spend hundreds of $$$ to run into this again?
  450. Any other ideas?
  451.  
  452. - Darren
  453.  
  454. ==========================================================================
  455. Darren Giles, Technical Director                        Terran Interactive
  456. For info on Cleaner QuickTime compression, visit http://www.Terran-Int.com
  457.  
  458. +++++++++++++++++++++++++++
  459.  
  460. >From checker@netcom.com (Chris Hecker)
  461. Date: Sat, 9 Mar 1996 21:05:04 GMT
  462. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  463.  
  464. mars@netcom.com (Darren Giles) writes:
  465. >Should I be thrilled that CodeWarrior seems better than it gets credit for?
  466. >Should I be disappointed that MrC didn't provide the edge I hoped for?
  467.  
  468. You should be disappointed because all of the Mac PowerPC compilers are
  469. disappointing in my opinion.  My next article in Game Developer
  470. Magazine (Jun/Jul, I think) is a Mac compiler review of sorts (CW8,
  471. SC8, MrC, and Motorola), and the conclusion I came to (at least for
  472. floating point code) is that you need to hold your compiler's hand if
  473. you care at all about the generated code.
  474.  
  475. > Any other ideas?
  476.  
  477. The differences between compilers was far less than the difference
  478. between hand optimized C and naive C, so your best bet is to look at
  479. the generated code on whatever compiler you're using and figure out
  480. what stupid stuff the compiler is doing.  Then, try to figure out how
  481. you can write your source to give the compiler a clue.
  482.  
  483. Chris
  484.  
  485.  
  486. +++++++++++++++++++++++++++
  487.  
  488. >From checker@netcom.com (Chris Hecker)
  489. Date: Tue, 12 Mar 1996 06:41:17 GMT
  490. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  491.  
  492. checker@netcom.com (Chris Hecker) writes:
  493. >disappointing in my opinion.  My next article in Game Developer
  494. >Magazine (Jun/Jul, I think) is a Mac compiler review of sorts (CW8,
  495. >SC8, MrC, and Motorola), 
  496.  
  497. I forgot, I also covered the Microsoft VC++ cross compiler.
  498.  
  499. Chris
  500.  
  501. ---------------------------
  502.  
  503. >From at@neuro.psy.soton.ac.uk (Adriaan Tijsseling)
  504. Subject: Desktop pattern for a window
  505. Date: Mon, 11 Mar 1996 09:34:41 +0000
  506. Organization: Electronics and Computer Science, University of Southampton
  507.  
  508. Hi,
  509.  
  510. I am using pixelpatterns as a background for a window and I want to use
  511. the pixelpattern that is used for the desktop. How can I access the 
  512. desktop pattern. Which trap do I need to use?
  513.  
  514. Many thanks in advance,
  515.  
  516. Adriaan Tijsseling
  517.  
  518. +++++++++++++++++++++++++++
  519.  
  520. >From bore01@mail.macs.mankato.mn.us (Patrick Bores)
  521. Date: Mon, 11 Mar 1996 17:51:32 -0600
  522. Organization: Flatline Software
  523.  
  524. In article <at-1103960934410001@sm1.psy.soton.ac.uk>,
  525. at@neuro.psy.soton.ac.uk (Adriaan Tijsseling) wrote:
  526.  
  527. > Hi,
  528. > I am using pixelpatterns as a background for a window and I want to use
  529. > the pixelpattern that is used for the desktop. How can I access the 
  530. > desktop pattern. Which trap do I need to use?
  531. > Many thanks in advance,
  532. > Adriaan Tijsseling
  533.  
  534. That's an easy one. The desktop pattern is ID 16 in the System file.
  535.  
  536. FillWindowWithDeskPattern(WindowPtr TheWindow){
  537.    PixPatHandle DeskPat;
  538.  
  539.    DeskPat = GetPixPat(16);
  540.    FillCRect(&TheWindow->portRect,DeskPat);
  541. }
  542.  
  543. That should do it.
  544. Patrick
  545.  
  546. +++++++++++++++++++++++++++
  547.  
  548. >From jakeg@voyager.co.nz (Jake Grover)
  549. Date: Tue, 12 Mar 1996 22:33:48 +1200
  550. Organization: OzEmail Pty Ltd - Australia
  551.  
  552. > I am using pixelpatterns as a background for a window and I want to use
  553. > the pixelpattern that is used for the desktop. How can I access the 
  554. > desktop pattern. Which trap do I need to use?
  555.  
  556. OK.. I know this is different, but perhaps two birds could be killed here
  557. with the same stone.  How do you get the utility pattern in System 7.5?
  558.  
  559.  
  560. Jake
  561.  
  562. +++++++++++++++++++++++++++
  563.  
  564. >From at@neuro.psy.soton.ac.uk (Adriaan Tijsseling)
  565. Date: Wed, 13 Mar 1996 20:38:50 +0000
  566. Organization: Electronics and Computer Science, University of Southampton
  567.  
  568. In article <jakeg-1203962233480001@ts1p34.net.auckland.voyager.co.nz>,
  569. jakeg@voyager.co.nz (Jake Grover) wrote:
  570.  
  571. > > I am using pixelpatterns as a background for a window and I want to use
  572. > > the pixelpattern that is used for the desktop. How can I access the 
  573. > > desktop pattern. Which trap do I need to use?
  574. > OK.. I know this is different, but perhaps two birds could be killed here
  575. > with the same stone.  How do you get the utility pattern in System 7.5?
  576.  
  577.  
  578. I got several replies on this. There is a routine called 
  579. LMGetDeskCPat() which returns the pixpathandle of the desktop pattern. You
  580. can also retrieve this by calling GetPixPat(16). To get the Utilities
  581. pattern
  582. call this with the number 42 as argument. 
  583.  
  584. It works perfect!
  585.  
  586. Adriaan Tijsseling
  587. ______________________________________________________________
  588.  
  589. Work:
  590.    Cognitive Sciences Centre
  591.    Department of Psychology
  592.    University of Southampton
  593.    United Kingdom
  594.  
  595. Homepages:
  596.    work: http://www.soton.ac.uk/~coglab/coglab
  597.    life: http://www.soton.ac.uk/~agt/
  598.  
  599. E-mail:
  600.    at@neuro.psy.soton.ac.uk
  601.    at@cogsci.ecs.soton.ac.uk
  602.    agt@oak.soton.ac.uk
  603. ______________________________________________________________
  604.  
  605. ---------------------------
  606.  
  607. >From elliott@mpi-muelheim.mpg.de (Mark Elliott)
  608. Subject: Direct-to-screen drawing and Copland
  609. Date: Thu, 14 Mar 1996 15:37:43 +0100
  610. Organization: Max-Planck-Institut f. Kohlenforsch. Muelheim
  611.  
  612. Hi All,
  613.  
  614. There has been a bit of debate about this, and I just got my latest
  615. developer mailing today, and here's the verdict.
  616.  
  617. (not an exact quote, but the content of the quote is specific)
  618.  
  619. 'Apple realises that some applications (specifically games are mentioned)
  620. NEED (my emphasis) direct-to-screen drawing. As long as you follow the
  621. guidelines set forth in the Develop article by Brigham Stevens (issue 11
  622. ?) then applications using this technique will still work under Copland
  623. (assuming you don't break any other rules, of course!)'.
  624.  
  625. What this means is locking PixMaps. Getting base address using
  626. GetPixBaseAddr(), etc.
  627.  
  628. I have not interpreted the text. It is all there in black and white. So
  629. one possible cause for game-programmers to worry about Copland is sorted.
  630.  
  631. hope this reassures you.
  632.  
  633. Mark
  634.  
  635. - ------------------------------------------------------------------
  636. Mark C Elliott                           elliott@mpi-muelheim.mpg.de
  637. Max-Planck-Institut                      voice: (+49) 208 306 2429
  638. Fuer Kohlenforschung
  639. Muelheim, Germany
  640. - ------------------------------------------------------------------
  641.  
  642. ---------------------------
  643.  
  644. >From Romeo Chua <rchua@st.nepean.uws.edu.au>
  645. Subject: Shareware Modula-2 compiler for Mac
  646. Date: 11 Mar 1996 03:37:57 GMT
  647. Organization: UWS Nepean, Department Of Computing
  648.  
  649. Can anybody tell me if there is a shareware Modula-2 compiler for the 
  650. Mac?
  651.  
  652. Regards
  653. Romeo Chua
  654.  
  655.  
  656. +++++++++++++++++++++++++++
  657.  
  658. >From ldubois@syndetics.be (Luc Dubois)
  659. Date: Tue, 12 Mar 1996 10:21:30 +0100
  660. Organization: Syndetics Research
  661.  
  662. In article <4i076l$40h@ob1.uws.EDU.AU>,
  663. Romeo Chua <rchua@st.nepean.uws.edu.au> wrote:
  664.  
  665. > Can anybody tell me if there is a shareware Modula-2 compiler for the 
  666. > Mac?
  667. Romeo,
  668.  
  669. There is MacMETH from the ETH in Switzerland, home of N. Wirth. The
  670. package can be found on the excellent Apprentice CD or online at
  671. <ftp://baikal.ethz.ch/pub/mac/RAMSES> (according to the readme file).
  672. Note that if you're looking for native PPC support you'll have to 
  673. look elsewhere: the authors make it clear that they do not intend
  674. to add that. A lot of people at ETH consider Modula-2 a dead end now
  675. and are switching to Oberon-2 (Wirth's successor to Modula-2). There
  676. are 4 different Oberon compilers/environments for Macintosh on the 
  677. cited cd. Oberon can be a bit confusing at first, since it is both the
  678. name of the language and an OS/development environment. And the latter
  679. isn't like anything else you (or your intended customer audience)
  680. might have seen before, or are willing to put up with, so be warned :-).
  681.  
  682. You might also want to check out a very great www-page dedicated to
  683. Oberon which contains hundreds of references to (mainly) Oberon
  684. material but also has some references to Modula-2 compilers. The URL 
  685. is <http://www.math.tau.ac.il/~laden/Ob-pkgs.html>.
  686.  
  687. Good luck,
  688.  
  689. Luc
  690. - ---------------------
  691. THEY may well be C-Borg. 
  692. THEY may well think resistance is futile. 
  693. *I* will damn well not be ass-C-milated. 
  694.  
  695.  
  696.  
  697.  
  698.  
  699. ---------------------------
  700.  
  701. >From jeff@leland.Stanford.EDU (Jeffrey Matthew Bergan)
  702. Subject: Sharing Name
  703. Date: 27 Feb 1996 02:31:19 -0800
  704. Organization: Stanford University, CA 94305, USA
  705.  
  706. Howdy,
  707.  
  708.     I'm trying to write a program that will change the name of the mac
  709. (The one that appears in the Sharing Setup control panel), but I can't
  710. seem to find how.  I would be very greatfull if anyone could give me any
  711. advice on how to set this name.  Thanks.
  712.  
  713.                     Jeff Bergan
  714.                     jeff@leland.Stanford.EDU
  715.  
  716. PS. I would also appreciate it if anyone who responds would send a copy to
  717. me through e-mail.  Thanks a bunch.
  718.  
  719. +++++++++++++++++++++++++++
  720.  
  721. >From jumplong@aol.com (Jump Long)
  722. Date: 12 Mar 1996 01:57:06 -0500
  723. Organization: America Online, Inc. (1-800-827-6364)
  724.  
  725. Jeffrey Matthew Bergan wrote:
  726. >I'm trying to write a program that will change the name of the
  727. >mac (The one that appears in the Sharing Setup control panel),
  728. >but I can't seem to find how.  I would be very greatfull if
  729. >anyone could give me any advice on how to set this name. 
  730. >Thanks.
  731.  
  732. There's no API to do that and Apple specifically warns you not to do that.
  733. If you really have a need to let the user change the name of their system,
  734. then you should probably just send the Finder an AppleEvent to tell it to
  735. open the Sharing Setup control panel.
  736.  
  737. - Jim Luther
  738.  
  739. +++++++++++++++++++++++++++
  740.  
  741. >From grinch@buffnet.net (The Grinch)
  742. Date: 13 Mar 1996 20:39:45 GMT
  743. Organization: Vortex Software
  744.  
  745. In article <4i3782$a1q@newsbf02.news.aol.com>, jumplong@aol.com (Jump
  746. Long) wrote:
  747.  
  748. > Jeffrey Matthew Bergan wrote:
  749. > >I'm trying to write a program that will change the name of the
  750. > >mac
  751.  
  752. Call this with (-16413, 'My Mac'). It's not pretty, but it does work.
  753.  
  754. -The Grinch B-)
  755.  
  756.    function setSysSTR (ID: integer; s: str255): str255;
  757.       const
  758.          strTipe = 'STR ';
  759.       var
  760.          funkyResFile: integer;
  761.          resident: handle;
  762.          myErr: OSErr;
  763.    begin
  764.       funkyResFile := curResFile;
  765.       useResFile(0);
  766.  
  767.       resident:=get1Resource(strTipe, ID);
  768.       if resident=nil then begin {create resource}
  769.             resident:=newHandle(0);
  770.             AddResource(resident, strTipe, ID, '');
  771.             myErr:=resError;
  772.             if myErr=noErr then {OK}
  773.                writeResource(resident)
  774.             else
  775.                disposeHandle(resident);
  776.          end
  777.       else
  778.          myErr:=noErr; {OK}
  779.  
  780.       if myErr=noErr then begin {resident is a valid res handle}
  781.             setHandleSize(resident, length(s)+1);
  782.             HLock(resident);
  783.             BlockMove(@s, resident^, length(s)+1); {+length byte}
  784.             HUnlock(resident);
  785.             ChangedResource(resident);
  786.             myErr:=resError;
  787.             if myErr=noErr then begin
  788.                   writeResource(resident);
  789.                   myErr:=resError;
  790.                end;
  791.             releaseResource(resident);
  792.          end; {resident exists}
  793.       useResFile(funkyResFile);
  794.       setSysSTR := strErr(myErr);
  795.    end;
  796.  
  797. +++++++++++++++++++++++++++
  798.  
  799. >From grinch@buffnet.net (The Grinch)
  800. Date: 15 Mar 1996 21:31:50 GMT
  801. Organization: Vortex Software
  802.  
  803. > > > >I'm trying to write a program that will change the name of the
  804. > > > >mac
  805. > > 
  806. > > Call this with (-16413, 'My Mac'). It's not pretty, but it does work.
  807. > > 
  808. > > -The Grinch B-)
  809. > > 
  810. > > code to alter system file removed
  811. > And right after this, you might as well force a reboot.
  812.  
  813. Actually, I did. That was cut from a program that sets up computer labs.
  814.  
  815. -The Grinch
  816.  
  817. ---------------------------
  818.  
  819. >From fred@lightside.net (Fred Condo)
  820. Subject: Writing a scriptable app
  821. Date: Sun, 03 Mar 1996 00:10:25 -0800
  822. Organization: Lightside, Inc. - Internet Access
  823.  
  824. So... I've been off doing things besides writing Mac applications for a
  825. couple years, but now I have a need to write a small app or FBA that needs
  826. to be scriptable via AppleScript. I've read and understood the AppleEvent
  827. Manager chapter of IM-VI.
  828.  
  829. What documentation should I read to get me jumpstarted on this task?
  830. Pointers to sample code would be great too. Thank you!
  831. -- 
  832. http://www.lightside.net/~fred/ + net access + http://www.lightside.net/
  833. "Attempts to control the use of encryption technology are wrong in
  834. principle, unworkable in practice, and damaging to the long term economic
  835. value of the information networks." - UK Labour Party
  836.  
  837. +++++++++++++++++++++++++++
  838.  
  839. >From jonpugh@netcom.com (Jon Pugh)
  840. Date: Sun, 10 Mar 1996 20:25:34 GMT
  841. Organization: Apple Computer
  842.  
  843. In article <fred-0303960010260001@st-ursen.lightside.net>,
  844. fred@lightside.net (Fred Condo) wrote:
  845.  
  846. >So... I've been off doing things besides writing Mac applications for a
  847. >couple years, but now I have a need to write a small app or FBA that needs
  848. >to be scriptable via AppleScript. I've read and understood the AppleEvent
  849. >Manager chapter of IM-VI.
  850. >
  851. >What documentation should I read to get me jumpstarted on this task?
  852. >Pointers to sample code would be great too. Thank you!
  853.  
  854. The simplest solution is to use a framework, like TCL2, PowerPlant or
  855. MacApp 3.3.  All of these have the majority of the work done for you.  Any
  856. other course of action will require you to write your own AE framework.
  857.  
  858. The net question is, how complex is your app?  If it is ultra-simple, as
  859. most FBAs are, then you might be able to get away with just writing a set
  860. of handlers.  The real question is about your content model.  What data
  861. are you trying to expose?  The complexity of this will determine how much
  862. framework you will need.  The simpler your content model, the more likely
  863. you can just use a set of simple handlers.  The more complex your model,
  864. the more likely you are to benefit from the framework route.
  865.  
  866. Jon
  867.  
  868. -- 
  869. What are YOU doing to oppose the Microsoft juggernaut?
  870.          http://www.infoworkshop.com/~jonpugh/
  871.  
  872. ---------------------------
  873.  
  874. >From julian@cs.auckland.ac.nz (Julian Harris)
  875. Subject: [Q] How to write a FAT inline LDEF
  876. Date: Fri, 08 Mar 1996 10:54:36 +1300
  877. Organization: Computer Science, The University of Auckland
  878.  
  879. Hi all,
  880.  
  881. A common Mac programmer trick to get over the ugliness of LDEFs is to make
  882. them inline. You do this by calling LNew with a 0 LDEF ID so it reverts to
  883. the system LDEF then you allocate a handle that contains a JMP instruction
  884. to your actual LDEF in your code. It's way cool - it's easy to debug and
  885. develop with such a mechanism. 
  886.  
  887. However, in the world of PowerPC does anyone know how to do such a thing
  888. and make it PowerMac native? A friend suggested that the only change that
  889. will work is having my LDEF stub jump to a UPP, but this means a mixed
  890. mode switch for every call which is insanely ugly. But then I guess so is
  891. the original hack.
  892.  
  893. Any comments?
  894.  
  895. TIA!
  896. .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
  897.                                                 >  Julian Harris, Programmer   >
  898. By doing just a little every day,              >  Comp. Sci. Dept.     x8915  >
  899. you can gradually let the task                >  The University of Auckland  >
  900. completely overwhelm you.                    >  julian@cs.auckland.ac.nz    >
  901.  
  902. +++++++++++++++++++++++++++
  903.  
  904. >From devon@apple.com (Devon Hubbard)
  905. Date: Thu, 14 Mar 1996 20:04:04 -0800
  906. Organization: Apple Computer
  907.  
  908. In article <julian-0803961054360001@julian.cs.auckland.ac.nz>,
  909. julian@cs.auckland.ac.nz (Julian Harris) wrote:
  910.  
  911. > A common Mac programmer trick to get over the ugliness of LDEFs is to make
  912. > them inline. You do this by calling LNew with a 0 LDEF ID so it reverts to
  913. > the system LDEF then you allocate a handle that contains a JMP instruction
  914. > to your actual LDEF in your code. It's way cool - it's easy to debug and
  915. > develop with such a mechanism. 
  916.  
  917. Actually, the steps involve using the same LDEF procID you would in your
  918. regular LNew call and setting up of the dummy LDEF handle BEFORE calling
  919. LNew.
  920.  
  921. > However, in the world of PowerPC does anyone know how to do such a thing
  922. > and make it PowerMac native? A friend suggested that the only change that
  923. > will work is having my LDEF stub jump to a UPP, but this means a mixed
  924. > mode switch for every call which is insanely ugly. But then I guess so is
  925. > the original hack.
  926. > Any comments?
  927.  
  928. I hate to nitpick further but there typically won't be such a thing as a
  929. 'FAT' inline LDEF.  You application is going to either be 68k or PPC so
  930. the dummy LDEF stub is going to jump back to either but not both.  Of
  931. course one could setup a LDEF stub to be FAT with ptrs to 68k and PPC code
  932. somewhere else beside the running app.
  933.  
  934. I'm not sure if you needed the code, but here's one way to setup an LDEF
  935. so it jumps back into your PPC application making it (the LDEF) easier to
  936. debug.  
  937.  
  938. Hope this helps.
  939.  
  940. dEVoN
  941.  
  942. - --------
  943. The items to be defined here are:
  944.  
  945.    procID - the LDEF proc id you'll be using in LNew().
  946.    LDEFMain - the name of the LDEF code's main entry point.
  947.               (it won't be called main() when linked into your app)
  948.  
  949. // For testing LDEF code inline with a project
  950. // This code modifies the 'LDEF' rsrc in RAM to jump back into a
  951. // statically linked LDEF routine built into the app so it can be
  952. // easily debugged.
  953.    ProcInfoType kLDEFprocInfo = kPascalStackBased
  954.        | STACK_ROUTINE_PARAMETER(1, kTwoByteCode)
  955.        | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Boolean)) )
  956.        | STACK_ROUTINE_PARAMETER(3, kFourByteCode)
  957.        | STACK_ROUTINE_PARAMETER(4, kFourByteCode)
  958.        | STACK_ROUTINE_PARAMETER(5, kTwoByteCode)
  959.        | STACK_ROUTINE_PARAMETER(6, kTwoByteCode)
  960.        | STACK_ROUTINE_PARAMETER(7, kFourByteCode);
  961.  
  962.       Handle      theLDEFH = GetResource('LDEF', procID);
  963.       if (theLDEFH)
  964.          {
  965.          #ifdef   powerc
  966.          UniversalProcPtr  procUPP = NewRoutineDescriptor((ProcPtr)LDEFMain,
  967.                                  kLDEFprocInfo ,GetCurrentISA());
  968.          if (procUPP)
  969.             {
  970.             long  procSize = GetPtrSize((Ptr)procUPP);
  971.             SetHandleSize( theLDEFH, procSize);
  972.             if (!MemError())
  973.                BlockMove( procUPP, (*theLDEFH), procSize);
  974.             
  975.             HNoPurge(theLDEFH);
  976.             }
  977.          #else
  978.          • Sorry, NO 68K LDEF stub code yet! (intentional compile err)
  979.          #endif
  980.          }
  981.  
  982.    ... go on to call LNew with the same 'procID'
  983. - ---------
  984.  
  985. ---------------------------
  986.  
  987. >From support@fluxsoft.com (Maurice Volaski)
  988. Subject: [Q] Where is the NBP queue located on an Open Transport-based Mac?
  989. Date: Wed, 06 Mar 1996 02:27:25 -0500
  990. Organization: Flux Software
  991.  
  992. I have some code that is trying to obtain a pointer to the table of
  993. registered NBP entities on a Mac. Here is the snippet:
  994.  
  995. MPPParamBlock anMPP;
  996. NamesTableEntry *theNamesTable;
  997.  
  998. if(PGetAppleTalkInfo(&anMPP,false)==0)                                                               
  999. // find the registered names table.
  1000. {
  1001.  theNamesTable=(NamesTableEntry *)anMPP.GAIINFO.nTQueue;
  1002. }
  1003.  
  1004. The above code works fine on standard Appletalk-based Macs, but on an Open
  1005. Transport (1.0.8)-based 8500, theNamesTable is zero. Does anyone know why
  1006. this is happening?
  1007.  
  1008. --
  1009. Maurice Volaski, Flux Software         support@fluxsoft.com
  1010. http://www.fluxsoft.com/     ftp://ftp.fluxsoft.com
  1011.  
  1012. +++++++++++++++++++++++++++
  1013.  
  1014. >From jumplong@aol.com (Jump Long)
  1015. Date: 9 Mar 1996 04:47:55 -0500
  1016. Organization: America Online, Inc. (1-800-827-6364)
  1017.  
  1018. >I have some code that is trying to obtain a pointer to the table
  1019. >of registered NBP entities on a Mac. Here is the snippet:
  1020. >
  1021. >MPPParamBlock anMPP; NamesTableEntry *theNamesTable;
  1022. >
  1023. >if(PGetAppleTalkInfo(&anMPP,false)==0)                          
  1024. >                                     // find the registered
  1025. >names table. {
  1026. > theNamesTable=(NamesTableEntry *)anMPP.GAIINFO.nTQueue; }
  1027. >
  1028. >The above code works fine on standard Appletalk-based Macs, but
  1029. >on an Open Transport (1.0.8)-based 8500, theNamesTable is zero.
  1030. >Does anyone know why this is happening?
  1031.  
  1032. My guess is that they don't want you mucking with the names table
  1033. directly.
  1034.  
  1035. Using the names table directly was never very safe unless you disabled
  1036. interrupts completely while walking the linked list. That's because
  1037. PRemoveName can be called at interrupt time and that makes it possible for
  1038. your code crash if the names table entry you're looking at or about to
  1039. look (if you already have its address) at gets unlinked from the list adn
  1040. the memory gets reused.
  1041.  
  1042. If you want the list of names on your system, you can turn on self-send
  1043. mode with PSetSelfSend, do a PLookupName using the entity name "=", the
  1044. entity type "=", and the zone "*" (the local zone), and then filter out
  1045. all matches that don't have your system's node and net address (get that
  1046. with GetNodeAddress).
  1047.  
  1048. - Jim Luther
  1049.  
  1050. ---------------------------
  1051.  
  1052. >From zzkbergm@dingo.uq.edu.au (Christoph Bergmann)
  1053. Subject: gworlds 7.5.3
  1054. Date: Tue, 12 Mar 1996 19:05:53 +1000
  1055. Organization: University of Queensland
  1056.  
  1057.  
  1058. heres an interesting one.. dunno whos fault it is, dont care, just wanted
  1059. to point it out..
  1060.  
  1061. NewGWorld with a bitdepth of 24 on my powermac 7100/80 w 16bit 14"
  1062. monitor, returns a param error...
  1063. (err-157 invalid pixel depth)
  1064. pre 7.5.3 it worked fine..
  1065.  
  1066. just in case anyone wanted to know :)
  1067.  
  1068. chris
  1069.  
  1070. +++++++++++++++++++++++++++
  1071.  
  1072. >From pottier@jonque.ens.fr (Francois Pottier)
  1073. Date: 13 Mar 1996 16:44:35 GMT
  1074. Organization: Ecole Normale Superieure, Paris
  1075.  
  1076. In article <zzkbergm-1203961905530001@zzkbergm.slip.cc.uq.oz.au>,
  1077. Christoph Bergmann <zzkbergm@dingo.uq.edu.au> wrote:
  1078.  
  1079. >pre 7.5.3 it worked fine..
  1080.  
  1081. Well, they have fixed a bug :-) 24 was not a valid bit depth.
  1082. Of course it might be annoying to some people...
  1083.  
  1084. -- 
  1085. Francois Pottier
  1086. Francois.Pottier@ens.fr
  1087. Francois.Pottier@inria.fr
  1088. http://www.eleves.ens.fr:8080/home/pottier/
  1089.  
  1090. +++++++++++++++++++++++++++
  1091.  
  1092. >From bwade@qualia.com (Bretton Wade)
  1093. Date: Tue, 12 Mar 1996 10:38:37 -0500
  1094. Organization: qualia, inc.
  1095.  
  1096. pixel depth should be set to 32...
  1097.  
  1098. In article <zzkbergm-1203961905530001@zzkbergm.slip.cc.uq.oz.au>,
  1099. zzkbergm@dingo.uq.edu.au (Christoph Bergmann) wrote:
  1100.  
  1101. # heres an interesting one.. dunno whos fault it is, dont care, just wanted
  1102. # to point it out..
  1103. # NewGWorld with a bitdepth of 24 on my powermac 7100/80 w 16bit 14"
  1104. # monitor, returns a param error...
  1105. # (err-157 invalid pixel depth)
  1106. # pre 7.5.3 it worked fine..
  1107. # just in case anyone wanted to know :)
  1108. # chris
  1109.  
  1110. -- 
  1111. bwade@qualia.com
  1112. http://www.qualia.com/
  1113.  
  1114.  
  1115. ---------------------------
  1116.  
  1117. End of C.S.M.P. Digest
  1118. **********************
  1119.